package com.simon.api.recommond;

import org.junit.Test;

import java.util.Map;
import java.util.Scanner;

/**
 * Created by changf on 2017/7/7.
 */
public class AddCartService {


    @Test
    public void add(){
        String userName="zhangsan";
        String item="ss";


    }


    public static void main(String[] args) {

        while(true) {
            Scanner sc = new Scanner(System.in);
            RedisService redisService = new RedisService();

            System.out.println("请输入你的操作:1)新增购物车 2)查看推荐 ");
            String type=sc.nextLine();
            if("1".equals(type)) {
                System.out.println("请输入你的用户名:");
                String userName = sc.nextLine();
                System.out.println("请输入你的购买项:");
                String itemName = sc.nextLine();
                redisService.addToCart(userName, itemName, 1);
                System.out.println("查看购物车" + userName + ":");
                Map<String, String> carts = redisService.getCart(userName);
                for (String key : carts.keySet()) {
                    System.out.println("商品名称:" + key + ",商品数量:" + carts.get(key));
                }
            }
            if("2".equals(type)) {
                System.out.println("请输入你的用户名:");
                String userName = sc.nextLine();
                Map<String, Double> recommend = redisService.getRecommend(userName);
                for (String key : recommend.keySet()) {
                    System.out.println("商品名称:" + key + ",推荐指数:" + recommend.get(key));
                }

            }


            }
    }
}
